package com.mail.manager.modular.service.impl.portal;

import com.mail.manager.common.node.ZTreeNode;
import com.mail.manager.core.datascope.DataScope;
import com.mail.manager.modular.mapper.ProductMapper;
import com.mail.manager.modular.model.Product;
import com.mail.manager.modular.service.portal.IProductService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 创建人： Shi Heng
 * 创建时间：2018-04-03 19:08
 * QQ：374696376
 * Description：
 */
@Service
public class ProductServiceImpl implements IProductService {

    @Resource
    ProductMapper productMapper;

    @Override
    public Product selectByPrimaryKey(Object id) {
        return productMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Map<String, Object>> list(String condition) {
        return productMapper.list(condition);
    }

    @Override
    public boolean insert(Product product) {
        Integer insert = productMapper.insert(product);
        if(insert>0)
            return true;
        return false;
    }

    @Override
    public List<ZTreeNode> tree() {
        return productMapper.tree();
    }

    @Override
    public List<Map<String, Object>> selectProducts(String title, String beginTime, String endTime, Integer product_category_id) {
        return productMapper.selectProducts(title,beginTime,endTime,product_category_id);
    }

    @Override
    public boolean delteObject(Integer id) {
        int delete = productMapper.deleteByPrimaryKey(id);
        if(delete>0)
            return true;
        return false;
    }

    @Override
    public boolean updateObjtById(Product product) {
        int update = productMapper.updateByPrimaryKey(product);
        if(update>0)
            return true;
        return false;
    }
}
